﻿Imports Microsoft.Reporting.WinForms

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim ch = (From c In dt.tbCuaHangs Select c).First

        Dim frm As New frmInDSKhachHang
        frm.Text = "Danh Sách Khách Hàng"
        frm.rptName = ".\ChiTMT\Report\KhachHang\rptDanhSachKhachHang.rdlc"
        frm.dsName = "dsDanhSachKhachHang"
        Dim bs As New BindingSource
        bs.DataSource = dt.tbKhachHangs.Where(Function(s) s.idCuaHang = ch.id)
        frm._bs = bs
        frm.ch = ch
        frm.ShowDialog()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim ch = (From c In dt.tbCuaHangs Select c).First
        Dim frm As New frmInDSKhachHang
        frm.Text = "Danh Sách Nhà Cung Cấp"
        frm.rptName = ".\ChiTMT\Report\NhaCungCap\rptDanhSachNhaCungCap.rdlc"
        frm.dsName = "dsDanhSachNhaCC"
        Dim bs As New BindingSource
        bs.DataSource = dt.tbNhaCungCaps.Where(Function(s) s.idCuaHang = ch.id)
        frm._bs = bs
        frm.ch = ch
        frm.ShowDialog()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim ch As New tbCuaHang With {.id = True}
        Dim frm As New frmInDSCuaHang
        frm.Text = "Danh Sách Cửa Hàng"
        frm.rptName = ".\ChiTMT\Report\CuaHang\rptDanhSachCuaHang.rdlc"
        frm.dsName = "dsDanhSachCuaHang"
        Dim bs As New BindingSource
        bs.DataSource = dt.tbCuaHangs
        frm._bs = bs
        frm.ShowDialog()
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Dim ch = (From c In dt.tbCuaHangs Select c).First

        Dim frm As New frmInDSKhachHang
        frm.Text = "Danh Sách Nhân Viên"
        frm.rptName = ".\ChiTMT\Report\NhanVien\rptDanhSachNhanVien.rdlc"
        frm.dsName = "dsDanhSachNhanVien"
        Dim bs As New BindingSource
        bs.DataSource = dt.tbNhanViens.Where(Function(s) s.idCuaHang = ch.id)
        frm._bs = bs
        frm.ch = ch
        frm.ShowDialog()
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim hd = dt.tbHoaDons.First
        frmInHoaDon.rpName = ".\ChiTMT\Report\HoaDon\rptHoaDon.rdlc"
        frmInHoaDon.HoaDon = hd
        frmInHoaDon.ShowDialog()
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        Dim px = dt.tbPhieuXuats.First
        frmInPhieuXuatNhap.rpName = ".\ChiTMT\Report\PhieuXuat\rptPhieuXuat.rdlc"
        frmInPhieuXuatNhap.nhapxuat = False
        frmInPhieuXuatNhap.PhieuXuat = px
        frmInPhieuXuatNhap.ShowDialog()
    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        Dim px = dt.tbPhieuNhaps.First
        frmInPhieuXuatNhap.rpName = ".\ChiTMT\Report\PhieuNhap\rptPhieuNhap.rdlc"
        frmInPhieuXuatNhap.nhapxuat = True
        frmInPhieuXuatNhap.PhieuNhap = px
        frmInPhieuXuatNhap.ShowDialog()
    End Sub

    Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
        Dim hd = dt.tbHoaDons.First
        frmInHoaDon.rpName = ".\ChiTMT\Report\HoaDon\rptHoaDonA6.rdlc"
        frmInHoaDon.HoaDon = hd
        frmInHoaDon.ShowDialog()
    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        Dim hd = dt.tbHoaDons.First
        frmInHoaDon.rpName = ".\ChiTMT\Report\HoaDon\rptHoaDonA5.rdlc"
        frmInHoaDon.HoaDon = hd
        frmInHoaDon.ShowDialog()
    End Sub

    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        Dim ch = (From c In dt.tbCuaHangs Select c).First
        Dim frm As New frmInDSKhachHang
        frm.Text = "Danh Sách Nhân Viên"
        frm.rptName = ".\ChiTMT\Report\HoaDon\rptDanhSachHoaDon.rdlc"
        frm.dsName = "dsDanhSachHoaDon"
        Dim bs As New BindingSource
        bs.DataSource = dt.tbHoaDons.Where(Function(s) s.idCuaHang = ch.id)
        frm._bs = bs
        frm.ch = ch
        frm.ShowDialog()
    End Sub
End Class
